package com.egg.ylt.presenter.impl;

import com.egg.ylt.Utils.API;
import com.egg.ylt.pojo.CheckAppVersionEntity;
import com.egg.ylt.presenter.ICheckAppVersionPresenter;
import com.egg.ylt.view.ICheckAppVersionView;
import com.yonyou.framework.library.bean.ErrorBean;
import com.yonyou.framework.library.common.CommonUtils;
import com.yonyou.framework.library.mvp.impl.BasePresenter;
import com.yonyou.framework.library.net.ReqCallBack;
import com.yonyou.framework.library.net.RequestManager;

import java.util.HashMap;

public class CheckAppVersionPresenterImpl extends BasePresenter<ICheckAppVersionView> implements ICheckAppVersionPresenter {
    @Override
    public void checkAppVersion(String appVersion, String appPort) {
        mView.showDialogLoading("数据加载中");
        HashMap<String, String> hashMap = new HashMap<>();
        hashMap.put("appVersion", appVersion);
        hashMap.put("appPort", appPort);
        RequestManager.getInstance().requestPostByAsyn(API.POST_CHECK_VERSION, hashMap, new ReqCallBack<CheckAppVersionEntity>() {

            @Override
            public void onReqSuccess(CheckAppVersionEntity result) {
                mView.dismissDialogLoading();
                mView.checkType(result);
            }

            @Override
            public void onFailure(String result) {
                mView.dismissDialogLoading();
                CommonUtils.makeEventToast(mContext, result, false);
            }

            @Override
            public void onReqFailed(ErrorBean error) {
                mView.dismissDialogLoading();
                CommonUtils.makeEventToast(mContext, error.getMsg(), false);
            }
        });
    }
}
